package org.dizena.utils;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

public class FileUtil
{

    public static boolean createFile(byte[] bs, String name)
    {
        File file = new File(name);
        if (file.exists())
        {
            boolean b1 = file.delete();
        }

        if (!file.getParentFile().exists())
        {
            boolean b2 = file.getParentFile().mkdirs();
        }

        try
        {
            OutputStream outputStream = new FileOutputStream(name);
            outputStream.write(bs);
            outputStream.flush();
            outputStream.close();
            return true;
        } catch (IOException e)
        {
            e.printStackTrace();
        }
        return false;
    }

    public static void deleteFile(File file)
    {
        boolean b = file.delete();
    }

    public static void deleteFile(String name)
    {
        File file = new File(name);
        if (file.exists())
        {
            boolean b = file.delete();
        }

    }

}
